<div class="breadcrumb">
    <ul id="breadcrumb">
        <li><a href="<?php echo Configure::read('base_url');?>backstage" title="Home">
		<?php echo $this->Html->image("home.png", array("alt" => "Home",'class'=>'home','border'=>'0'));?>
		</a></li>
               <li>Reported Items</li>
    </ul>
</div>
<?php echo $this->element('admin/admin_leftmenu'); ?>
<div id="left"> 

    <?php
    echo $this->Session->flash();
    if ($this->Session->check('Message.auth'))
        echo $this->Session->flash('auth');
    ?>
    <div class="div_header"><?php __('Reported Items'); ?></div>
    <div class="div_content">
        <div class="paging">
          <a href="javascript:void(0);" controller="products" action="addnote_reportitem" onclick='showPop(this)'>
            <input type="button" value="Add Note" /></a>
	</div>
      <table id="category_table" cellspacing="0" class="tablesorter">
            <thead>
               <tr style="background:gray;">
			<th><input type="checkbox" id="select_all" /></th>
			<th>&nbsp;</th>
			<th>Item #</th>
			<th>Title</th>
			<th>Seller</th>
			<th>Reported By</th>
                        <th class="actions"><?php __('Actions');?></th>
	</tr>
            </thead>
            <tbody>
                <?php
                if(!empty ($products)){
               $i = 0;
               //pr($products);
                foreach ($products as $product):
                    $class = null;
                    if ($i++ % 2 == 0) 
                    $class = ' class="alt"';
                    
                ?>
                                  
                    <tr class="fullrow<?php echo $product['Product']['id']; ?>">
                    <td <?php echo $class;?>  style="vertical-align: middle;"><input type="checkbox" class="products_id" id="<?php echo $product['Product']['id']; ?>" value="<?php echo $product['Product']['id']; ?>" /></td>
                    <td <?php echo $class;?>  style="vertical-align: middle;"><?php echo'<img src="'.Configure::read('base_url').'img/uploads/'.$product['Product']['products_thumbnailImage'].'" alt="'.$product['Product']['products_title'].'" width="80" border="0" />';?></td>
                    <td <?php echo $class;?>  style="vertical-align: middle;">
                     <?php echo $product['Product']['id']; ?>
                    </td>
                    <td  <?php echo $class;?>  style="vertical-align: middle;"><?php echo $product['Product']['products_title']; ?></td>
                    <td <?php echo $class;?>  style="vertical-align: middle;"><?php echo $product['Product']['User']['username']; ?></td>
                    <td <?php echo $class;?>  style="vertical-align: middle;"><?php echo $product['Reporter']['username']; ?></td>
        <td align="center"  <?php echo $class;?> style="vertical-align: middle;">
            <?php if($session->read('grouptype')!='S-Admins'){ ?>
            <a href="javascript:void(0);" controller="products" action="product_disapproved" title="product_disapproved"
               ElmID="<?php echo $product['Product']['id']; ?>" onclick='showPop(this)'>
            <input type="button" value="End" id="<?php echo $product['Product']['id']; ?>"/>
            </a>
            <br/><br/>
            <?php } ?>
            <input type="button" value="Ignore" id="<?php echo $product['Reporteditem']['id']; ?>" class="ignore"/> ||
            <a href="javascript:void(0);" controller="products" action="addnote_reporteditem" title="add note"
               ElmID="<?php echo $product['Product']['id']; ?>" onclick='showPop(this)'>
            <input type="button" value="Add Note" /></a><br/><br/>
           <a href="<?php echo Configure::read('base_url');?>backstage/messages/new_message/<?php echo $product['Product']['user_id'];?>">
           <input type="button" value="Contact Seller" />
           </a> ||
           <a href="javascript:void(0);" controller="products" action="product_disapproved" title="product_disapproved"
               ElmID="<?php echo $product['Product']['id']; ?>" onclick='showPop(this)'>
            <input type="button" value="End" id="<?php echo $product['Product']['id']; ?>"/>
            </a>
            
        </td>
             </tr>
               
        <?php
        $comments = $this->requestAction('/products/getnotereport/'.$product['Product']['id'].'/'.$product['Product']['user_id']);
        //pr($comments);
        //$comments =null;
        if(!empty ($comments)){
?>
       <tr    class="fullrow<?php echo $product['Product']['id']; ?>">
            <td colspan="8" id="disnote<?php echo $product['Product']['id']; ?>" style="background: none repeat scroll 0pt 0pt BlanchedAlmond;">
    <?php
        
        foreach($comments as $comment) {
        echo '<b>'.$comment['User']['username'].' [ '.date('d-m-Y g:i A',  strtotime($comment['Reportnote']['created'])).' ] : </b> '.$comment['Reportnote']['note'];echo"<br/>";
        //$j++;

        }
?>
</td></tr>
        <?php
        }
        ?>
        <?php
        endforeach;
        }else{
        ?>
        <tr>
        <td colspan="7">
        No Reported Item Found.
        </td></tr>
        <?php
        }
        ?>
                    <tbody>
                </table>
        <div class="paging">
		<?php
                echo $this->Paginator->prev('<< ' . __('previous', true), array(), null, array('class'=>'disabled'));?>
	 | 	<?php echo $this->Paginator->numbers();?>
 |
		<?php echo $this->Paginator->next(__('next', true) . ' >>', array(), null, array('class' => 'disabled'));?>
	</div>
            </div>
            <div class="div_bottom"></div>
        </div>

        <!-- edit sidebar items here -->

        </div>

<?php echo $html->script(array("jquery.pagination.js", "jquery.tablesorter.min.js", "jquery.tablednd.js","jquery.validate.js")); ?>
<script type="text/javascript"> 
     jQuery(document).ready(function(){
        jQuery("#category_table").tablesorter({headers: {0:{sorter: false},1:{sorter: false},6:{sorter: false}}});

jQuery("#select_all").click(function(){
				var checked_status = this.checked;
				jQuery("input[class=products_id]").each(function()
				{
                                 this.checked = checked_status;
    				});
});

jQuery(".ignore").click(function()
			{                            
                            var id=jQuery(this).attr('id');                           
                            //alert(id);
                            jQuery.ajax({
                                url : baseurl+"products/delete_reportitem/"+id,
                                        success : function (html) {
                                            window.location.reload();
                                            }
                                            });
                               });


});
</script>